package ja;

import com.gui.ssm.entity.User;
import com.gui.ssm.mapper.UserMapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserMapperCase {
    AbstractApplicationContext ac;
    private UserMapper userMapper;

    @Test
    public void inset(){
        System.out.println(ac);
        User user = new User();
        user.setUsername("gui");
        user.setPassword("1234");
        user.setPhone("23455");
        user.setEmail("34325");
        Integer rows = userMapper.insert(user);
        System.out.println(rows);
    }

    @Test
    public void findByUsername(){
        String username = "qiqi";
        User user = userMapper.findByUsername(username);
        System.out.println("user:" + user);
    }
    @Before
    public void doBefore(){
        ac = new ClassPathXmlApplicationContext("spring-dao.xml");
        userMapper = ac.getBean("userMapper",UserMapper.class);

    }

    @After
    public void doAfter(){
        ac.close();
    }



}
